<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        #divbox{
           height:300px;
           width:300px;
           background-color: red;
        }
        #pbox{
           height:100px;
           width:100px;
           background-color: green;
        }
    </style>
</head>
<body>
    <div id="divbox">
        <p id="pbox"></p>
    </div>
    <script>
        //移入 移出  mouseover mouseout  有冒泡的
        //忽略层级的关系
        // divbox.onmouseover=function(){
        //    console.log("div移入");
        // }
        // divbox.onmouseout=function(){
        //    console.log("div移出");
        // }

        // pbox.onmouseover=function(){
        //     console.log("p移入");
        // }
        // pbox.onmouseout=function(){
        //     console.log("p移出");
        // }

        //mouseenter mouseleave  没有冒泡
        //存在层级之间的关系
        divbox.onmouseenter=function(){
           console.log("div移入");
        }
        divbox.onmouseleave=function(){
           console.log("div移出");
        }

        pbox.onmouseenter=function(){
            console.log("p移入");
        }
        pbox.onmouseleave=function(){
            console.log("p移出");
        }
    </script>
</body>
</html>